package com.zhc.dejingapi.controller;


import com.github.pagehelper.PageInfo;
import com.zhc.dejingapi.common.result.Result;
import com.zhc.dejingapi.entity.QingInjectreportEntity;
import com.zhc.dejingapi.entity.query.CodeQuery;
import com.zhc.dejingapi.entity.vo.Code2Vo;
import com.zhc.dejingapi.entity.vo.QingInjectAndSendWorkVo;
import com.zhc.dejingapi.service.QingInjectreportService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhc
 * @since 2024-10-10
 */
@RestController
@RequestMapping("/qing-injectreport")
@CrossOrigin
public class QingInjectreportController {


    @Resource
    private QingInjectreportService qingInjectreportService;
    @PostMapping("/reportJob")
    public Result reportJob(@RequestBody QingInjectAndSendWorkVo qingInjectAndSendWorkVo){
        return qingInjectreportService.reportJob(qingInjectAndSendWorkVo);

    }

    @PostMapping("/updateReport")
    public Result updateReport(@RequestBody QingInjectAndSendWorkVo qingInjectAndSendWorkVo){
        return qingInjectreportService.updateReport(qingInjectAndSendWorkVo);
    }
    @PostMapping("/deleteReport")
    public Result deleteReport(@RequestBody QingInjectreportEntity qingInjectreport){

        return qingInjectreportService.deleteReport(qingInjectreport);
    }

    @PostMapping("selectReport")
    public Map<Object, Object> selectReport(@RequestBody CodeQuery codeQuery){

        PageInfo<QingInjectreportEntity> page=qingInjectreportService.selectReport(codeQuery);
        Map<Object, Object> map = new HashMap<>();
        map.put("records",page.getList());
        map.put("total",page.getTotal());
        return  map;
    }

    @PostMapping("/getCodeList")
    private Map<Object, Object> getCodeList(@RequestBody CodeQuery codeQuery){
        PageInfo<Code2Vo> page = qingInjectreportService.getCodeList(codeQuery);
        Map<Object, Object> map = new HashMap<>();
        map.put("records",page.getList());
        map.put("total",page.getTotal());
        return  map;
    }

    @PostMapping("/reportBoilJob")
    public Result reportBoilJob(@RequestBody QingInjectAndSendWorkVo qingInjectAndSendWorkVo){
        return qingInjectreportService.reportBoilJob(qingInjectAndSendWorkVo);
    }

    @PostMapping("/getReportStartTime/{processPlanCode}")
    public Result getReportStartTime(@PathVariable String processPlanCode){
        return qingInjectreportService.getReportStartTime(processPlanCode);
    }


}
